package org.yufan.core.result;

/**
 * Created by zxd on 2019/3/6
 **/
public class ResultUtils {

    /**
     * 1.成功不带返回数据
     * @return
     */
    public static Result buildSuccess(){
        Result result=new Result();
        result.setStatus("success");
        result.setCode(20000);
        return result;
    }

    /**
     * 2.成功带返回数据
     * @return
     */
    public static Result buildSuccess(Object data){
        Result result=new Result();
        result.setStatus("success");
        result.setCode(20000);
        result.setData(data);
        return result;
    }

    /**
     * 3.失败
     * @return
     */
    public static Result buildFail(Integer code,String message){
        Result result=new Result();
        result.setStatus("fail");
        result.setCode(code);
        result.setMessage(message);
        return result;
    }

    /**
     * 失败  枚举
     * @param statusCode
     * @return
     */
    public static Result buildFail(StatusCode statusCode){
        return buildFail(statusCode.getCode(),statusCode.getMessage());
    }

}
